﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TransCend.Model;

namespace TransCend.Result
{
    [Serializable]
    public class DataResult : Result
    {

        private Dictionary<string, object> jmap = new Dictionary<string, object>();

        public DataResult()
        {
           
        }

        public object this[string key]
        {
            get { return jmap[key]; }
            set { jmap[key] = value; }
        }

        private bool ContainsKey(string key)
        {
            return jmap.ContainsKey(key);
        }

        public T GetData<T>()
        {
            if (this.ContainsKey("data"))
            {
                return (T)this["data"];
            }
            return default(T);
        }

        public void SetData(Object data)
        {
            this["data"] = data;
        }

        public override object ToJsonObject()
        {
            jmap["errorCode"] = errorCode;
            jmap["success"] = success;
            jmap["message"] = message;
            return jmap;
        }
        
    }
}
